package com.weixing.mall.pay;

import lombok.Data;

/**
 * @ClassName PayResult
 * @Description
 * @Author Small
 * @Date 2019/11/28 9:59
 * @Version 1.0
 **/
@Data
public class PayResult {
    private static final String SUCCESS = "SUCCESS";
    private static final String FAIL = "FAIL";
    private static final String UNKONW_EXCEPTION = "UNKONW_EXCEPTION";


    private String status;
    private String msg;
    private String errCode;
    private Object data;

    public PayResult() { }


    public PayResult(String status, String msg, String errCode, Object data) {
        this.status = status;
        this.msg = msg;
        this.errCode = errCode;
        this.data = data;
    }


    /**
     * 方法描述:  接口调用成功成功
     * @Author Small
     * @param data  需要返回的数据
     * @Date 2019/11/28 16:46
     * @return com.weixing.mall.pay.PayResult
     */
    public static PayResult success(Object data) {
        return new PayResult(SUCCESS, null, null, data);
    }

    /**
     * 方法描述: 接口调用失败
     * @Author Small
     * @param errCode  错误代码
     * @param errMsg   失败原因
     * @Date 2019/11/28 16:48
     * @return com.weixing.mall.pay.PayResult
     */
    public static PayResult fail(String errCode, String errMsg) {
        return new PayResult(FAIL, errMsg, errCode, null);
    }

    /**
     * 方法描述: 接口调用失败
     * @Author Small
     * @Date 2019/11/28 16:48
     * @return com.weixing.mall.pay.PayResult
     */
    public static PayResult unknowException() {
        return new PayResult(UNKONW_EXCEPTION, "系统未知异常", null, null);
    }



    /**
     * 方法描述: 是否成功
     * @Author Small
     * @param
     * @Date 2019/11/28 16:49
     * @return boolean
    */
    public boolean isSuccess() {
        return SUCCESS.equals(this.status);
    }
}
